# -*- coding: UTF-8 -*-
from openpyxl import load_workbook
import random

SocketID = "10001"
wb = load_workbook(filename = './param.xlsx')#打开参数表excel
sheet_ranges = wb.active

def UpdateSocketID():
	SocketID = str(random.randint(10000,19999))#随机生成0~9999的数字最为socket编号

def GetStartMsg():
	str1 = SocketID + '10011'#随机生成0~9999的数字最为socket编号
	str1 += "#dev_no=" + str(sheet_ranges['A2'].value) + "#chl_no=" + str(sheet_ranges['B2'].value) + "#oper_flag=1#step_file=" + str(sheet_ranges['C2'].value).replace("\\","\\\\")#单斜杠替换双斜杠
	str1 = str(len(str1)).zfill(8) + str1#统计前面字符串大小并补齐数位与之前的字符相加
	print(str1)
	return str1


def GetStopMsg():
	str1 = SocketID + "10021#dev_no=" + str(sheet_ranges['A2'].value) + "#chl_no=" + str(sheet_ranges['B2'].value) + "#oper_flag=1"
	str1 = str(len(str1)).zfill(8) + str1#统计前面字符串大小并补齐数位与之前的字符相加
	return str1
#GetStartMsg()